
#line 1 "..\user\main.c" /0
 
 
 
 
  
#line 1 "..\user\myconfig.h" /0
 
 
 typedef signed char INT8S; 
 typedef unsigned char INT8U; 
 
 typedef unsigned char uchar;
 typedef signed int INT16S;
 typedef unsigned int INT16U;
 typedef unsigned long INT32U;
 typedef signed long INT32S;
 
 
 typedef unsigned int uint;
 
 
  
#line 1 "..\user\STC8.H" /0
 
 
 
 
 
 
 
 
 sfr ACC         =   0xe0;
 sfr B           =   0xf0;
 sfr PSW         =   0xd0;
 sbit CY         =   PSW^7;
 sbit AC         =   PSW^6;
 sbit F0         =   PSW^5;
 sbit RS1        =   PSW^4;
 sbit RS0        =   PSW^3;
 sbit OV         =   PSW^2;
 sbit P          =   PSW^0;
 sfr SP          =   0x81;
 sfr DPL         =   0x82;
 sfr DPH         =   0x83;
 sfr TA          =   0xae;
 sfr DPS         =   0xe3;
 sfr DPL1        =   0xe4;
 sfr DPH1        =   0xe5;
 
 
 
 sfr P0          =   0x80;
 sfr P1          =   0x90;
 sfr P2          =   0xa0;
 sfr P3          =   0xb0;
 sfr P4          =   0xc0;
 sfr P5          =   0xc8;
 sfr P6          =   0xe8;
 sfr P7          =   0xf8;
 sfr P0M0        =   0x94;
 sfr P0M1        =   0x93;
 sfr P1M0        =   0x92;
 sfr P1M1        =   0x91;
 sfr P2M0        =   0x96;
 sfr P2M1        =   0x95;
 sfr P3M0        =   0xb2;
 sfr P3M1        =   0xb1;
 sfr P4M0        =   0xb4;
 sfr P4M1        =   0xb3;
 sfr P5M0        =   0xca;
 sfr P5M1        =   0xc9;
 sfr P6M0        =   0xcc;
 sfr P6M1        =   0xcb;
 sfr P7M0        =   0xe2;
 sfr P7M1        =   0xe1;
 
 sbit P00        =   P0^0;
 sbit P01        =   P0^1;
 sbit P02        =   P0^2;
 sbit P03        =   P0^3;
 sbit P04        =   P0^4;
 sbit P05        =   P0^5;
 sbit P06        =   P0^6;
 sbit P07        =   P0^7;
 sbit P10        =   P1^0;
 sbit P11        =   P1^1;
 sbit P12        =   P1^2;
 sbit P13        =   P1^3;
 sbit P14        =   P1^4;
 sbit P15        =   P1^5;
 sbit P16        =   P1^6;
 sbit P17        =   P1^7;
 sbit P20        =   P2^0;
 sbit P21        =   P2^1;
 sbit P22        =   P2^2;
 sbit P23        =   P2^3;
 sbit P24        =   P2^4;
 sbit P25        =   P2^5;
 sbit P26        =   P2^6;
 sbit P27        =   P2^7;
 sbit P30        =   P3^0;
 sbit P31        =   P3^1;
 sbit P32        =   P3^2;
 sbit P33        =   P3^3;
 sbit P34        =   P3^4;
 sbit P35        =   P3^5;
 sbit P36        =   P3^6;
 sbit P37        =   P3^7;
 sbit P40        =   P4^0;
 sbit P41        =   P4^1;
 sbit P42        =   P4^2;
 sbit P43        =   P4^3;
 sbit P44        =   P4^4;
 sbit P45        =   P4^5;
 sbit P46        =   P4^6;
 sbit P47        =   P4^7;
 sbit P50        =   P5^0;
 sbit P51        =   P5^1;
 sbit P52        =   P5^2;
 sbit P53        =   P5^3;
 sbit P54        =   P5^4;
 sbit P55        =   P5^5;
 sbit P56        =   P5^6;
 sbit P57        =   P5^7;
 sbit P60        =   P6^0;
 sbit P61        =   P6^1;
 sbit P62        =   P6^2;
 sbit P63        =   P6^3;
 sbit P64        =   P6^4;
 sbit P65        =   P6^5;
 sbit P66        =   P6^6;
 sbit P67        =   P6^7;
 sbit P70        =   P7^0;
 sbit P71        =   P7^1;
 sbit P72        =   P7^2;
 sbit P73        =   P7^3;
 sbit P74        =   P7^4;
 sbit P75        =   P7^5;
 sbit P76        =   P7^6;
 sbit P77        =   P7^7;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 sfr PCON        =   0x87;
 
 
 
 
 
 
 
 
 sfr AUXR        =   0x8e;
 
 
 
 
 
 
 
 
 sfr AUXR2       =   0x97;
 
 sfr BUS_SPEED   =   0xa1;
 sfr P_SW1       =   0xa2;
 sfr P_SW2       =   0xba;
 
 sfr VOCTRL      =   0xbb;
 sfr RSTCFG      =   0xff;
 
 
 
 
 
 
 
 
 
 
 sfr IE          =   0xa8;
 sbit EA         =   IE^7;
 sbit ELVD       =   IE^6;
 sbit EADC       =   IE^5;
 sbit ES         =   IE^4;
 sbit ET1        =   IE^3;
 sbit EX1        =   IE^2;
 sbit ET0        =   IE^1;
 sbit EX0        =   IE^0;
 sfr IE2         =   0xaf;
 
 
 
 
 
 
 
 sfr IP          =   0xb8;
 sbit PPCA       =   IP^7;
 sbit PLVD       =   IP^6;
 sbit PADC       =   IP^5;
 sbit PS         =   IP^4;
 sbit PT1        =   IP^3;
 sbit PX1        =   IP^2;
 sbit PT0        =   IP^1;
 sbit PX0        =   IP^0;
 sfr IP2         =   0xb5;
 
 
 
 
 
 
 
 sfr IPH         =   0xb7;
 
 
 
 
 
 
 
 
 sfr IP2H        =   0xb6;
 
 
 
 
 
 
 
 sfr INTCLKO     =   0x8f;
 
 
 
 
 
 
 sfr AUXINTIF    =   0xef;
 
 
 
 
 
 
 
 
 sfr TCON        =   0x88;
 sbit TF1        =   TCON^7;
 sbit TR1        =   TCON^6;
 sbit TF0        =   TCON^5;
 sbit TR0        =   TCON^4;
 sbit IE1        =   TCON^3;
 sbit IT1        =   TCON^2;
 sbit IE0        =   TCON^1;
 sbit IT0        =   TCON^0;
 sfr TMOD        =   0x89;
 
 
 
 
 
 
 
 
 sfr TL0         =   0x8a;
 sfr TL1         =   0x8b;
 sfr TH0         =   0x8c;
 sfr TH1         =   0x8d;
 sfr T4T3M       =   0xd1;
 
 
 
 
 
 
 
 
 sfr T4H         =   0xd2;
 sfr T4L         =   0xd3;
 sfr T3H         =   0xd4;
 sfr T3L         =   0xd5;
 sfr T2H         =   0xd6;
 sfr T2L         =   0xd7;
 sfr TH4         =   0xd2;
 sfr TL4         =   0xd3;
 sfr TH3         =   0xd4;
 sfr TL3         =   0xd5;
 sfr TH2         =   0xd6;
 sfr TL2         =   0xd7;
 sfr WKTCL       =   0xaa;
 sfr WKTCH       =   0xab;
 
 sfr WDT_CONTR   =   0xc1;
 
 
 
 
 
 
 sfr SCON        =   0x98;
 sbit SM0        =   SCON^7;
 sbit SM1        =   SCON^6;
 sbit SM2        =   SCON^5;
 sbit REN        =   SCON^4;
 sbit TB8        =   SCON^3;
 sbit RB8        =   SCON^2;
 sbit TI         =   SCON^1;
 sbit RI         =   SCON^0;
 sfr SBUF        =   0x99;
 sfr S2CON       =   0x9a;
 
 
 
 
 
 
 
 
 sfr S2BUF       =   0x9b;
 sfr S3CON       =   0xac;
 
 
 
 
 
 
 
 
 sfr S3BUF       =   0xad;
 sfr S4CON       =   0x84;
 
 
 
 
 
 
 
 
 sfr S4BUF       =   0x85;
 sfr SADDR       =   0xa9;
 sfr SADEN       =   0xb9;
 
 
 sfr ADC_CONTR   =   0xbc;
 
 
 
 sfr ADC_RES     =   0xbd;
 sfr ADC_RESL    =   0xbe;
 sfr ADCCFG      =   0xde;
 
 
 
 sfr SPSTAT      =   0xcd;
 
 
 sfr SPCTL       =   0xce;
 
 
 
 
 
 
 sfr SPDAT       =   0xcf;
 
 
 sfr IAP_DATA    =   0xc2;
 sfr IAP_ADDRH   =   0xc3;
 sfr IAP_ADDRL   =   0xc4;
 sfr IAP_CMD     =   0xc5;
 
 
 
 
 sfr IAP_TRIG    =   0xc6;
 sfr IAP_CONTR   =   0xc7;
 
 
 
 
 sfr ISP_DATA    =   0xc2;
 sfr ISP_ADDRH   =   0xc3;
 sfr ISP_ADDRL   =   0xc4;
 sfr ISP_CMD     =   0xc5;
 sfr ISP_TRIG    =   0xc6;
 sfr ISP_CONTR   =   0xc7;
 
 
 sfr CMPCR1      =   0xe6;
 
 
 
 
 
 
 
 
 sfr CMPCR2      =   0xe7;
 
 
 
 
 sfr CCON        =   0xd8;
 sbit CF         =   CCON^7;
 sbit CR         =   CCON^6;
 sbit CCF3       =   CCON^3;
 sbit CCF2       =   CCON^2;
 sbit CCF1       =   CCON^1;
 sbit CCF0       =   CCON^0;
 sfr CMOD        =   0xd9;
 
 
 sfr CL          =   0xe9;
 sfr CH          =   0xf9;
 sfr CCAPM0      =   0xda;
 
 
 
 
 
 
 
 sfr CCAPM1      =   0xdb;
 
 
 
 
 
 
 
 sfr CCAPM2      =   0xdc;
 
 
 
 
 
 
 
 sfr CCAPM3      =   0xdd;
 
 
 
 
 
 
 
 sfr CCAP0L      =   0xea;
 sfr CCAP1L      =   0xeb;
 sfr CCAP2L      =   0xec;
 sfr CCAP3L      =   0xed;
 sfr CCAP0H      =   0xfa;
 sfr CCAP1H      =   0xfb;
 sfr CCAP2H      =   0xfc;
 sfr CCAP3H      =   0xfd;
 sfr PCA_PWM0    =   0xf2;
 sfr PCA_PWM1    =   0xf3;
 sfr PCA_PWM2    =   0xf4;
 sfr PCA_PWM3    =   0xf5;
 
 
 sfr PWMCFG      =   0xf1;
 
 
 sfr PWMIF       =   0xf6;
 
 
 
 
 
 
 
 
 sfr PWMFDCR     =   0xf7;
 
 
 
 
 
 
 
 
 sfr PWMCR       =   0xfe;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#line 16 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\rtx51tny.h" /0






 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 extern unsigned char os_create_task     (unsigned char task_id);
 extern unsigned char os_delete_task     (unsigned char task_id);
 
 extern unsigned char os_wait            (unsigned char typ, 
 unsigned char ticks,
 unsigned int dummy);
 extern unsigned char os_wait1           (unsigned char typ);
 extern unsigned char os_wait2           (unsigned char typ,
 unsigned char ticks);
 
 extern unsigned char os_send_signal     (unsigned char task_id);
 extern unsigned char os_clear_signal    (unsigned char task_id);
 extern unsigned char isr_send_signal    (unsigned char task_id);
 
 extern void          os_set_ready       (unsigned char task_id);
 extern void          isr_set_ready      (unsigned char task_id);
 
 extern unsigned char os_running_task_id (void);
 extern unsigned char os_switch_task     (void); 
 
 extern void          os_reset_interval  (unsigned char ticks);
 
 
#line 17 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\string.h" /0







 
 
 
 
 
 
 
 typedef unsigned int size_t;
 
 
 
 
 
 
 #pragma SAVE
 #pragma REGPARMS
 extern char  *strcat  (char *s1, const char *s2);
 extern char  *strncat (char *s1, const char *s2, size_t n);
 
 extern char   strcmp  (const char *s1, const char *s2);
 extern char   strncmp (const char *s1, const char *s2, size_t n);
 
 extern char  *strcpy  (char *s1, const char *s2);
 extern char  *strncpy (char *s1, const char *s2, size_t n);
 
 extern size_t strlen  (const char *);
 
 extern char  *strchr  (const char *s, char c);
 extern int    strpos  (const char *s, char c);
 extern char  *strrchr (const char *s, char c);
 extern int    strrpos (const char *s, char c);
 
 extern size_t strspn  (const char *s, const char *set);
 extern size_t strcspn (const char *s, const char *set);
 extern char  *strpbrk (const char *s, const char *set);
 extern char  *strrpbrk(const char *s, const char *set);
 extern char  *strstr  (const char *s, const char *sub);
 extern char  *strtok  (char *str, const char *set);
 
 extern char   memcmp  (const void *s1, const void *s2, size_t n);
 extern void  *memcpy  (void *s1, const void *s2, size_t n);
 extern void  *memchr  (const void *s, char val, size_t n);
 extern void  *memccpy (void *s1, const void *s2, char val, size_t n);
 extern void  *memmove (void *s1, const void *s2, size_t n);
 extern void  *memset  (void *s, char val, size_t n);
 #pragma RESTORE
 
 
#line 18 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\STDLIB.h" /0







 
 
 
 
 
 
#line 14 "C:\Keil_v5\C51\Inc\STDLIB.h" /1
  
 
 
#line 17 "C:\Keil_v5\C51\Inc\STDLIB.h" /0
 
 
#line 19 "C:\Keil_v5\C51\Inc\STDLIB.h" /1
  
 
#line 21 "C:\Keil_v5\C51\Inc\STDLIB.h" /0
 
 
 
 typedef char wchar_t;
 
 
 
#line 28 "C:\Keil_v5\C51\Inc\STDLIB.h" /1
 
 
 
 
 
 
 
 
 
  
 
 
#line 40 "C:\Keil_v5\C51\Inc\STDLIB.h" /0
 
 
 
 
 
 
#line 46 "C:\Keil_v5\C51\Inc\STDLIB.h" /1
 
 
 
 
 
 
#line 52 "C:\Keil_v5\C51\Inc\STDLIB.h" /0
 
 #pragma SAVE
 #pragma REGPARMS
 
 extern char   cabs (char  val);
 
 extern int    abs  (int   val);
 
 extern long   labs (long  val);
 
 extern float  atof (const char *s1);
 extern long   atol (const char *s1);
 extern int    atoi (const char *s1);
 extern int    rand (void);
 extern void   srand (unsigned int seed);
 
 
#line 69 "C:\Keil_v5\C51\Inc\STDLIB.h" /1
 
  
 
 
#line 73 "C:\Keil_v5\C51\Inc\STDLIB.h" /0
 
 extern float         strtod  (const char *nptr, char **endptr);
 extern long          strtol  (const char *nptr, char **endptr, unsigned char base);
 extern unsigned long strtoul (const char *nptr, char **endptr, unsigned char base);
 
 
 
 extern void init_mempool          (void xdata *p, size_t size);
 extern void xdata *malloc  (size_t size);
 extern void free                  (void xdata *p);
 extern void xdata *realloc (void xdata *p, size_t size);
 extern void xdata *calloc  (size_t nmemb, size_t size);
 
 
#line 87 "C:\Keil_v5\C51\Inc\STDLIB.h" /1
 
 
#line 89 "C:\Keil_v5\C51\Inc\STDLIB.h" /0
 
 #pragma RESTORE
 
 
#line 19 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\math.h" /0







 
 
 
 
 
 
#line 14 "C:\Keil_v5\C51\Inc\math.h" /1
 
  
 
 
 
  
 
 
 
 
 
 
 
 
#line 28 "C:\Keil_v5\C51\Inc\math.h" /0
 
 #pragma SAVE
 #pragma REGPARMS
 
 extern char  cabs  (char  val);
 extern int    abs  (int   val);
 extern long  labs  (long  val);
 
 
 extern float fabs  (float val);
 extern float sqrt  (float val);
 extern float exp   (float val);
 extern float log   (float val);
 extern float log10 (float val);
 extern float sin   (float val);
 extern float cos   (float val);
 extern float tan   (float val);
 extern float asin  (float val);
 extern float acos  (float val);
 extern float atan  (float val);
 extern float sinh  (float val);
 extern float cosh  (float val);
 extern float tanh  (float val);
 extern float atan2 (float y, float x);
 
 extern float ceil  (float val);
 extern float floor (float val);
 extern float modf  (float val, float *n);
 extern float fmod  (float x, float y);
 extern float pow   (float x, float y);
 
 
#line 60 "C:\Keil_v5\C51\Inc\math.h" /1
 
 
 
#line 63 "C:\Keil_v5\C51\Inc\math.h" /0
 
 #pragma RESTORE
 
 
#line 20 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\absacc.h" /0






 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#line 28 "C:\Keil_v5\C51\Inc\absacc.h" /1
  
  
  
  
 
#line 33 "C:\Keil_v5\C51\Inc\absacc.h" /0
 
 
 
 
 
 
 
#line 40 "C:\Keil_v5\C51\Inc\absacc.h" /1
  
  
  
  
 
#line 45 "C:\Keil_v5\C51\Inc\absacc.h" /0
 
 
 
 
 
 
 
 
 
#line 21 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\intrins.h" /0






 
 
 
 
 
 #pragma SAVE
 
 
#line 15 "C:\Keil_v5\C51\Inc\intrins.h" /1
 
 
 
#line 18 "C:\Keil_v5\C51\Inc\intrins.h" /0
 
 extern void          _nop_     (void);
 extern bit           _testbit_ (bit);
 extern unsigned char _cror_    (unsigned char, unsigned char);
 extern unsigned int  _iror_    (unsigned int,  unsigned char);
 extern unsigned long _lror_    (unsigned long, unsigned char);
 extern unsigned char _crol_    (unsigned char, unsigned char);
 extern unsigned int  _irol_    (unsigned int,  unsigned char);
 extern unsigned long _lrol_    (unsigned long, unsigned char);
 extern unsigned char _chkfloat_(float);
 
#line 29 "C:\Keil_v5\C51\Inc\intrins.h" /1
 
 
 
#line 32 "C:\Keil_v5\C51\Inc\intrins.h" /0
 
 extern void          _push_    (unsigned char _sfr);
 extern void          _pop_     (unsigned char _sfr);
 
 
 #pragma RESTORE
 
 
 
#line 22 "..\user\myconfig.h" /0
 
  
#line 1 "..\user\msg_que.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 enum 
 {
 MSG_11_RQZHONG,
 MSG_11_YPZHONG,
 MSG_11_HHZHONG,
 MSG_11_CALC,
 MSG_11_SAVE,
 MSG_11_PRINTJG,
 MSG_11_XIUGAI,
 MSG_11_RECORD_READ,
 MSG_11_PRE,
 MSG_11_NEXT,
 };
 
 enum 
 {
 MSG_DATA_TP_data=0,
 
 };
 
 
 
 
 
 
 
 
 enum 
 {
 MSG_7_GETRECORD_SIZE,
 MSG_7_TOP,
 MSG_7_LOW,
 MSG_7_CALC,
 MSG_7_SAVE,
 MSG_7_PRINTJG,
 MSG_7_XIUGAI,
 MSG_7_RECORD_READ,
 MSG_7_PRE,
 MSG_7_NEXT,
 };
 
 enum 
 {
 
 MSG_1_CALC,
 MSG_1_SAVE,
 MSG_1_PRINTJG,
 MSG_1_XIUGAI,
 MSG_1_RECORD_READ_OK,
 MSG_1_PRE,
 MSG_1_NEXT,
 
 };
 
 
 enum 
 {   
 NOTIFYTIMER,
 NOTIFYREADRTC,
 };
 
 
 
 
 
 
 
 
 
 
 
 
 typedef unsigned char	bool;
 typedef unsigned char	byte;
 typedef unsigned int 	word;
 typedef unsigned long 	dword;
 
 typedef unsigned int  MSGTYPE;			 
 typedef unsigned int  MSGPOINT;			 
 
 static byte  i;
 static word  MsgPoolPoint=0;
 static word  MsgPoolPoint_tail=0;
 static MSGTYPE  msgType;
 static word  MsgPool[50][2];
 
 
 
 
 
 
 
 
 
 extern  word g_MsgReturnValue;		 
 
 extern void msg_queue_in(MSGTYPE msgType, MSGPOINT msgPoint);	
 extern byte msg_queue_out(void) ; 
 extern void msg_queue_clear(byte selMSG);
 
 
 
 
#line 23 "..\user\myconfig.h" /0
 
  
#line 1 "..\user\smart_timer.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 extern void smart_timer_server(void);
 
 extern byte smart_timer_idle_check(void);
 
 
 extern byte smart_timer_start(MSGTYPE msgType, MSGPOINT msgPoint, word wCounter, word several);
 
 extern void smart_timer_stop(byte number);
 
 
 
#line 24 "..\user\myconfig.h" /0
 
  
#line 1 "..\user\Init_IO.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 sbit   MAX6675_SCK = P7^7; 				
 sbit   MAX6675_CS  = P7^6;  				
 sbit   MAX6675_SO  = P7^5;  
 
 sbit DJ_FENGSHAN   =P7^3;	   
 sbit TP_POWR       =P7^2;	 
 sbit DJ_UP_DOWN    =P7^1;	   
 sbit DJ_SP         =P7^0;		  
 
 sbit OU_DOWN       =P3^7;    
 sbit OU_UP_HR      =P3^6;	     
 
 sbit OU_STEP_RST   =P5^0;	         
 sbit OU_STEP       =P5^1;   
 
 
 sbit PJiaRe        =P3^2;
 
 sbit FengMing=P2^6;
 
 
 sbit PKEY_LEFT      = P2^0;
 sbit PKEY_UP        = P2^1;
 sbit PKEY_OK        = P2^2;
 sbit PKEY_DOWN      = P2^3 ;
 sbit PKEY_RIGHT     = P2^4 ;
 
 
 
 






























 
 
 
 
#line 25 "..\user\myconfig.h" /0
 
 
  
#line 1 "..\user\cmd_queue.h" /0






 
 
 
 
  
#line 1 "..\user\hmi_driver.h" /0






 
 
 
 
 
 
 
 
  
#line 1 "..\user\hmi_user_uart.h" /0






 
 
 
 
 
 
  
#line 1 "..\user\STC8.H" /0
 
#line 2 "..\user\STC8.H" /1
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
 
  
 
 
 
  
 
 
 
 
 
  
  
  
  
  
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
 
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
 
  
  
  
  
  
  
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
  
 
 
 
 
 
  
  
  
  
  
  
  
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
  
  
  
  
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
  
 
 
  
  
  
  
  
  
  
  
 
 
  
  
  
  
  
  
  
  
 
 
 
 
 
 
  
  
  
 
 
 
  
 
 
 
  
  
 
  
  
  
  
  
  
 
 
 
 
 
 
 
  
  
  
  
 
 
  
  
  
  
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
  
 
  
  
 
 
 
 
 
 
 
 
 
 
  
  
 
 
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
 
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
 
  
  
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 
 
#line 590 "..\user\STC8.H" /0
 
#line 13 "..\user\hmi_user_uart.h" /0
 
 
 
 
 
 
 
 


 
 void ConfigUART(unsigned long baud1);
 void UartInit();



 
 void  SendChar(unsigned char c);
 
 
 
 
#line 15 "..\user\hmi_driver.h" /0
 
 





 
  unsigned short int CheckCRC16(unsigned char *buffer,unsigned short int n);
 



 
 void DelayMS(unsigned int n);
 


 
 void LockDeviceConfig(void);
 


 
 void UnlockDeviceConfig(void);
 





 
 void SetCommBps(unsigned char option);
 


 
 void SetHandShake(void);
 



 
 void SetFcolor(unsigned short int color);
 



 
 void SetBcolor(unsigned short int color);
 


 
 void GUI_CleanScreen();
 




 
 void SetTextSpace(unsigned char x_w, unsigned char y_w);
 





 
 void SetFont_Region(unsigned char enable,unsigned short int width,unsigned short int height );
 




 
 void SetFilterColor(unsigned short int fillcolor_dwon, unsigned short int fillcolor_up);
 







 
 void DisText(unsigned short int x, unsigned short int y,unsigned char back,unsigned char font,unsigned char *strings );
 







 
 void DisCursor(unsigned char enable,unsigned short int x, unsigned short int y,unsigned char width,unsigned char height );
 




 
 void DisFull_Image(unsigned short int image_id,unsigned char masken);
 






 
 void DisArea_Image(unsigned short int x,unsigned short int y,unsigned short int image_id,unsigned char masken);
 










 
 void DisCut_Image(unsigned short int x,unsigned short int y,unsigned short int image_id,unsigned short int image_x,unsigned short int image_y,
  unsigned short int image_l, unsigned short int image_w,unsigned char masken);
 







 
 void DisFlashImage(unsigned short int x,unsigned short int y,unsigned short int flashimage_id,unsigned char enable,unsigned char playnum);
 




 
 void GUI_Dot(unsigned short int x,unsigned short int y);
 






 
 void GUI_Line(unsigned short int x0, unsigned short int y0, unsigned short int x1, unsigned short int y1);
 





 
 void GUI_ConDots(unsigned char mode,unsigned short int *dot,unsigned short int dot_cnt);
 





 
 void GUI_Circle(unsigned short int x0, unsigned short int y0, unsigned short int r);
 





 
 void GUI_CircleFill(unsigned short int x0, unsigned short int y0, unsigned short int r);
 







 
 void GUI_Arc(unsigned short int x,unsigned short int y, unsigned short int r,unsigned short int sa, unsigned short int ea);
 






 
 void GUI_Rectangle(unsigned short int x0, unsigned short int y0, unsigned short int x1,unsigned short int y1 );
 






 
 void GUI_RectangleFill(unsigned short int x0, unsigned short int y0, unsigned short int x1,unsigned short int y1 );
 






 
 void GUI_Ellipse (unsigned short int x0, unsigned short int y0, unsigned short int x1,unsigned short int y1 );
 






 
 void GUI_EllipseFill (unsigned short int x0, unsigned short int y0, unsigned short int x1,unsigned short int y1 );
 






 
 void SetBackLight(unsigned char light_level);
 



 
 void SetBuzzer(unsigned char time);
 






 
 void SetTouchPaneOption(unsigned char enbale,unsigned char beep_on,unsigned char work_mode,unsigned char press_calibration);
 


 
 void	CalibrateTouchPane();
 


 
 void TestTouchPane();
 













 
 void WriteLayer(unsigned char layer);
 



 
 void DisplyLayer(unsigned char layer);
 



 
 void ClearLayer(unsigned char layer);
 





 
 void WriteUserFlash(unsigned long startAddress,unsigned short int length,unsigned char *_data);
 




 
 void ReadUserFlash(unsigned long startAddress,unsigned short int length);
 




 
 void CopyLayer(unsigned char src_layer,unsigned char dest_layer);
 



 
 void SetScreen(unsigned short int screen_id);
 


 
 void GetScreen();
 








 
 void SetScreenUpdateEnable(unsigned char enable);
 





 
 void SetControlFocus(unsigned short int screen_id,unsigned short int control_id,unsigned char focus);
 





 
 void SetControlVisiable(unsigned short int screen_id,unsigned short int control_id,unsigned char visible);
 





 
 void SetControlEnable(unsigned short int screen_id,unsigned short int control_id,unsigned char enable);
 




 
 void GetControlValue(unsigned short int screen_id,unsigned short int control_id);
 





 
 void SetButtonValue(unsigned short int screen_id,unsigned short int control_id,unsigned char value);
 





 
 void SetTextValue(unsigned short int screen_id,unsigned short int control_id,unsigned char *str);
 





 
 void SetProgressValue(unsigned short int screen_id,unsigned short int control_id,unsigned long value);
 





 
 void SetMeterValue(unsigned short int screen_id,unsigned short int control_id,unsigned long value);
 





 
 void SetSliderValue(unsigned short int screen_id,unsigned short int control_id,unsigned long value);
 





 
 void SetSelectorValue(unsigned short int screen_id,unsigned short int control_id,unsigned char item);
 




 
 void AnimationStart(unsigned short int screen_id,unsigned short int control_id);
 




 
 void AnimationStop(unsigned short int screen_id,unsigned short int control_id);
 




 
 void AnimationPause(unsigned short int screen_id,unsigned short int control_id);
 





 
 void AnimationPlayFrame(unsigned short int screen_id,unsigned short int control_id,unsigned char frame_id);
 




 
 void AnimationPlayPrev(unsigned short int screen_id,unsigned short int control_id);
 




 
 void AnimationPlayNext(unsigned short int screen_id,unsigned short int control_id);
 






 
 void GraphChannelAdd(unsigned short int screen_id,unsigned short int control_id,unsigned char channel,unsigned short int color);
 





 
 void GraphChannelDel(unsigned short int screen_id,unsigned short int control_id,unsigned char channel);
 







 
 void GraphChannelDataAdd(unsigned short int screen_id,unsigned short int control_id,unsigned char channel,unsigned char *pData,unsigned short int nDataLen);
 
 void GraphChannelADDByte(unsigned short int screen_id,unsigned short int control_id,unsigned char channel,unsigned char Data);





 
 void GraphChannelDataClear(unsigned short int screen_id,unsigned short int control_id,unsigned char channel);
 








 
 void GraphSetViewport(unsigned short int screen_id,unsigned short int control_id,short int x_offset,unsigned short int x_mul,short int y_offset,unsigned short int y_mul);
 
 void HistoryGraph2ChannelSetValueInt16(unsigned short int screen_id,unsigned short int control_id,unsigned short int channel1Value,unsigned short int channel2Value);
 



 
 void BatchBegin(unsigned short int screen_id);
 




 
 void BatchSetButtonValue(unsigned short int control_id,unsigned char state);
 




 
 void BatchSetProgressValue(unsigned short int control_id,unsigned long value);
 




 
 void BatchSetSliderValue(unsigned short int control_id,unsigned long value);
 




 
 void BatchSetMeterValue(unsigned short int control_id,unsigned long value);
 




 
 void BatchSetText(unsigned short int control_id,unsigned char *strings);
 




 
 void BatchSetFrame(unsigned short int control_id,unsigned short int frame_id);
 


 
 void BatchEnd();
 





 
 void SetTimer(unsigned short int screen_id,unsigned short int control_id,unsigned long timeout);
 




 
 void StartTimer(unsigned short int screen_id,unsigned short int control_id);
 




 
 void StopTimer(unsigned short int screen_id,unsigned short int control_id);
 




 
 void PauseTimer(unsigned short int screen_id,unsigned short int control_id);
 






 
 void SetControlBackColor(unsigned short int screen_id,unsigned short int control_id,unsigned short int color);
 






 
 void SetControlForeColor(unsigned short int screen_id,unsigned short int control_id,unsigned short int color);
 






 
 void ShowPopupMenu(unsigned short int screen_id,unsigned short int control_id,unsigned char show,unsigned short int focus_control_id);
 








 
 void ShowKeyboard(unsigned char show,unsigned short int x,unsigned short int y,unsigned char type,unsigned char option,unsigned char max_len);
 
 void GetRTC(void);
 void SetRecordValue(unsigned short int screen_id,unsigned short int control_id,unsigned char *str) ;   
 void SetRecordScrooPos(unsigned short int screen_id,unsigned short int control_id,unsigned short int Pos);    
 void DeletAllRecord(unsigned short int screen_id,unsigned short int control_id);   
 void GetRecordNum(unsigned short int screen_id,unsigned short int control_id)  ;  
 void ModifyRecord(unsigned short int screen_id,unsigned short int control_id,unsigned short int POSITION,unsigned char *str)  ;  
 void DeletRecord(unsigned short int screen_id,unsigned short int control_id,unsigned short int POSITION) ;   
 void SetRecordScrooPos(unsigned short int screen_id,unsigned short int control_id,unsigned short int Pos);	   
 void InsertRecord(unsigned short int screen_id,unsigned short int control_id,unsigned short int POSITION,unsigned char *str) ;   
 void ReadRecord(unsigned short int screen_id,unsigned short int control_id,unsigned short int Pos);    
 void SelectRecord(unsigned short int screen_id,unsigned short int control_id,unsigned short int POSITION) ;   





 
 void IconPlayFrame(unsigned short int screen_id,unsigned short int control_id,unsigned char frame_id);
 




 
 void IconPlayPrev(unsigned short int screen_id,unsigned short int control_id);
 




 
 void IconPlayNext(unsigned short int screen_id,unsigned short int control_id);
 
 
#line 11 "..\user\cmd_queue.h" /0
 
 
 typedef unsigned char qdata;
 typedef unsigned short qsize;
 typedef struct _QUEUE
 {
 qsize _head;  
 qsize _tail;   
 qdata _data[20];	 
 }QUEUE;
 


 
 extern void queue_reset(QUEUE* que);
 




 
 extern void queue_push(QUEUE* que,qdata _data);
 





 
 extern qsize queue_find_cmd(qdata *cmd,qsize buf_len);
 





 
 extern float queue_find_TP(qdata *buffer,qsize buf_len)	;
 extern qsize Touch_Press_Find(qdata *buffer,qsize buf_len);
 
 
#line 27 "..\user\myconfig.h" /0
 
  
#line 1 "C:\Keil_v5\C51\Inc\stdio.h" /0






 
 
 
 
 
 
 
 
 
 
#line 17 "C:\Keil_v5\C51\Inc\stdio.h" /1
  
 
#line 19 "C:\Keil_v5\C51\Inc\stdio.h" /0
 
 
#line 21 "C:\Keil_v5\C51\Inc\stdio.h" /1
  
 
 
#line 24 "C:\Keil_v5\C51\Inc\stdio.h" /0
 
 #pragma SAVE
 #pragma REGPARMS
 extern char _getkey (void);
 extern char getchar (void);
 extern char ungetchar (char);
 extern char putchar (char);
 extern int printf   (const char *, ...);
 extern int sprintf  (char *, const char *, ...);
 extern int vprintf  (const char *, char *);
 extern int vsprintf (char *, const char *, char *);
 extern char *gets (char *, int n);
 extern int scanf (const char *, ...);
 extern int sscanf (char *, const char *, ...);
 extern int puts (const char *);
 
 #pragma RESTORE
 
 
 
#line 28 "..\user\myconfig.h" /0
 
 
  
#line 1 "..\user\cmd_process.h" /0
 
 
  
#line 1 "..\user\hmi_driver.h" /0






 
 
 
#line 10 "..\user\hmi_driver.h" /1
  
 
  
  
  
  
 





 
 
 



 
 
 


 
 
 


 
 
 





 
 
 


 
 
 



 
 
 



 
 
 


 
 
 




 
 
 





 
 
 




 
 
 







 
 
 







 
 
 




 
 
 






 
 
 










 
 
 
 







 
 
 




 
 
 






 
 
 





 
 
 





 
 
 





 
 
 







 
 
 






 
 
 






 
 
 






 
 
 






 
 
 






 
 
 



 
 
 






 
 
 


 
 
 


 
 
 













 
 
 



 
 
 



 
 
 





 
 
 




 
 
 




 
 
 



 
 
 


 
 
 








 
 
 





 
 
 





 
 
 





 
 
 




 
 
 





 
 
 





 
 
 





 
 
 





 
 
 





 
 
 





 
 
 




 
 
 




 
 
 




 
 
 





 
 
 




 
 
 




 
 
 






 
 
 





 
 
 







 
 
 
 





 
 
 








 
 
 
 
 



 
 
 




 
 
 




 
 
 




 
 
 




 
 
 




 
 
 




 
 
 


 
 
 





 
 
 




 
 
 




 
 
 




 
 
 






 
 
 






 
 
 






 
 
 








 
 
 
 
 
 
 
 
 
 
 
 
 
 





 
 
 




 
 
 




 
 
 
 
#line 3 "..\user\cmd_process.h" /0
#line 3 "..\user\cmd_process.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 enum CtrlType
 {
 kCtrlUnknown=0x0,
 kCtrlButton=0x10,   
 kCtrlText,   
 kCtrlProgress,   
 kCtrlSlider,     
 kCtrlMeter,   
 kCtrlDropList,  
 kCtrlAnimation,  
 kCtrlRTC,  
 kCtrlGraph,  
 kCtrlTable,  
 kCtrlMenu, 
 kCtrlSelector, 
 kCtrlQRCode, 
 kCtrlRecord, 
 
 };
 
 
 
 
 typedef struct
 {
  unsigned char    cmd_head;   
 
  unsigned char    cmd_type;   
  unsigned char    ctrl_msg;    
  unsigned short int   screen_id;   
  unsigned short int   control_id;   
  unsigned char    control_type;  
 
  unsigned char    param[256]; 
 
  unsigned char  cmd_tail[4];    
 }CTRL_MSG,*PCTRL_MSG;
 
 
 
 void ProcessMessage( PCTRL_MSG msg, unsigned short int size );
 
 void NotifyScreen(unsigned short int screen_id);
 
 void NotifyTouchXY(unsigned char press,unsigned short int x,unsigned short int y);
 
 void NotifyButton(unsigned short int screen_id, unsigned short int control_id, unsigned char  state);
 
 void NotifyText(unsigned short int screen_id, unsigned short int control_id, unsigned char *str);
 
 void NotifyProgress(unsigned short int screen_id, unsigned short int control_id, unsigned long value);
 
 void NotifySlider(unsigned short int screen_id, unsigned short int control_id, unsigned long value);
 
 void NotifyMeter(unsigned short int screen_id, unsigned short int control_id, unsigned long value);
 
 void NotifyMenu(unsigned short int screen_id, unsigned short int control_id, unsigned char  item, unsigned char  state);
 
 void NotifySelector(unsigned short int screen_id, unsigned short int control_id, unsigned char  item);
 
 void NotifyTimer(unsigned short int screen_id, unsigned short int control_id,unsigned long value);
 
 void NotifyReadFlash(unsigned char status,unsigned char *_data,unsigned short int length);
 
 void NotifyWriteFlash(unsigned char status);
 
 void NotifyReadRTC(unsigned char year,unsigned char month,unsigned char week,unsigned char day,unsigned char hour,unsigned char minute,unsigned char second);
 
 
#line 30 "..\user\myconfig.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
#line 42 "..\user\myconfig.h" /1
  
 
#line 44 "..\user\myconfig.h" /0
 
#line 45 "..\user\myconfig.h" /1
  
 
#line 47 "..\user\myconfig.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 enum 
 {
 KUAIHUI=0,
 MANHUI,
 LUOJIA,
 HUIFA,
 HUIFA2,
 ZIXUAN,
 ZIXUAN2,  
 SHUIFEN,
 CHENGZHONG,
 FUWEI,
 KUAISU,
 KUAISU2,
 HENGZHONG,
 HENGZHONG2,
 QUANSHUI,
 FENXISHUI,
 GENGXIN,
 BIANHAO,
 };
 enum 
 {
 
 MSG_CREATE_TASK_MF,
 MSG_DELETE_TASK_MF,
 MSG_CREATE_TASK_TP,
 MSG_DELETE_TASK_TP,
 MSG_CREATE_TASK_SF,
 MSG_DELETE_TASK_SF,
 };
 
 
 enum 
 {
 WENDU_ERR=0,
 READFLASH_ERR,
 WRITEFLASH_ERR,
 RECIEVFULL_ERR, 
 };
 enum
 {   
 TOUCH_MSG_QIDONG,
 TOUCH_MSG_QUXIAO,
 TOUCH_MSG_WRITEUSERFLASH,
 TOUCH_MSG_WRITEUSERFLASH_OK,
 TOUCH_MSG_SHEDING,
 TOUCH_MSG_READUSERFLASH,
 TOUCH_MSG_READUSERFLASH_OK,
 TOUCH_MSG_REDEFAULT,    
 };
 
 
 struct PARAMETER
 {
  unsigned int ManHui_PWM; 
  unsigned int KuaiHui_PWM;
  unsigned int KuaiHui_QDTime; 
  unsigned int HuiFa_PWM;
  unsigned int HuiFa_wd ;
  unsigned int HuiFa_time;
  unsigned int LuoJia_PWM;
  unsigned int LuoJia_wd;
  unsigned int LuoJia_time; 
  unsigned int ShuiFen_PWM;
  unsigned int ShuiFen_wd;
  unsigned int ShuiFen_time;
  unsigned int ZiXuan_PWM;
  unsigned int ZiXuan_wd ;
  unsigned int ZiXuan_time;
  unsigned int HuiFa2_PWM;
  unsigned int HuiFa2_wd ;
  unsigned int HuiFa2_time;
 
  unsigned int ZiXuan2_wd ;
  unsigned int ZiXuan2_time;
  unsigned int ZiXuan3_wd ;
  unsigned int ZiXuan3_time;  
 
 
  unsigned char HongGan_Mod ;
  unsigned char GongLv;
  unsigned char Ta;
  unsigned char Tb;
  unsigned char Td;
  unsigned char bDaYin_No; 
 }	 ;
 
 extern   struct PARAMETER  	Param;
 
 extern	unsigned char CZ_Pos;
 
 
 struct YPCANSHU	   
 {
 char ShiJian[15];
 char BianHao[13];
 float RQZhong;
 float YPZhong;
 float HHZhong;
 float HuiFen;
 float GJHuiFen;
 float SF;
 float TP_data_msg;  
 } ;
 extern   struct YPCANSHU  	YP;
 extern bit bflash_b1ah; 
 extern bit bKaiShiLedFlash_b1fh; 
 extern bit bQuXiao_b10h;
 extern bit bQiDong_b11h;
 extern bit bKaiShi_b12h; 
 extern unsigned char XiangMu;
 extern bit bStarted;
 extern bit bSec_b19h;
 extern unsigned char  JinCheng53H;
 extern bit IicTxdRxd(unsigned char TxdByte,unsigned char RxdByte, unsigned char *IicDataBuf);
 
 extern data unsigned char SlvAddr;  
 extern data unsigned char SubAddr;  
 extern  unsigned long Seconds;
 extern unsigned char Flash_mod;
 extern float TP_data;
 extern unsigned int Record_Pos;
 
 
 
 void msg_Process_task_SF(unsigned char msg);
 void msg_Process_task_MF(unsigned char msg);
 void msg_Process_task_TP(unsigned char msg);
 void NotifyButton_SF(unsigned short int screen_id, unsigned short int control_id, unsigned char  state);
 void NotifyText_SF(unsigned short int screen_id, unsigned short int control_id, unsigned char *str);
 void NotifyMenu_SF(unsigned short int screen_id, unsigned short int control_id, unsigned char  item, unsigned char  state);
 void NotifyReadRTC_SF(unsigned char year,unsigned char month,unsigned char week,unsigned char day,unsigned char hour,unsigned char minute,unsigned char second);
 void NotifyReadFlash_SF(unsigned char status,unsigned char *_data,unsigned short int length);
 void NotifyRecord_SF(unsigned short int screen_id, unsigned short int control_id,unsigned char ctrl_msg,unsigned char* msg);
 
 void SetTextValueInt32(unsigned short int screen_id, unsigned short int control_id,long value);
 void SetTextValueFloat(unsigned short int screen_id, unsigned short int control_id,float value);
 void SetTextValueFloat2(unsigned short int screen_id, unsigned short int control_id,float value);
 void SetTextValueInt16wendu(unsigned short int screen_id, unsigned short int control_id,short int value);
 void SetTextValueInt16Time(unsigned short int screen_id, unsigned short int control_id,short int value);
 
 void PrintStr_SF(char* str);
 extern void init_Printer_SF(void);
#line 5 "..\user\main.c" /0
 
 void ConfigP0P1P2P3P4P5P6P7(void)
 {
 P0M1=0x00;		   
 P0M0=0x0a;  
 P1M1=0x00; 
 P1M0=0x00;	 
 P2M1=0x00;
 P2M0=0x40;	 
 P3M1=0xC0;     
 P3M0=0x04;	 
 P4M1=0x00; 
 P4M0=0x04;	  
 P5M1=0x03;    
 P5M0=0x00;		   
 P6M1=0x00; 
 P6M0=0x00;		   
 P7M1=0x00; 
 P7M0=0x0F;	 
 
 
 
 DJ_FENGSHAN  =0;
 TP_POWR      =1;
 DJ_UP_DOWN   =0;
 DJ_SP        =0;
 PJiaRe       =0;
 FengMing     =0;
 
 }
 
 
 void McuInit(void)
 {      
 
 

 
 
 
 
  (*(unsigned char volatile xdata *)0xfe01)=0;     
 ConfigP0P1P2P3P4P5P6P7();          
 
 
 IPH=0X08;
 IP=0x08; 
 EA=1;
 P1=0xff;
 }
 
 
 
 
 data int idata *   BGV=0xef;
 int BGV_DAT;
 long data res;
 void ADC_Isr(void) interrupt 5 
 {   static unsigned int data ls=0;
 ADC_CONTR &= ~0x20;       
 res += (4095-(((word)ADC_RES<<8)+ADC_RESL));  
 
 ls=++ls%4096;
 if(!ls)
 {   res>>=12;
 
 isr_send_signal(0);   
 }
 else ADC_CONTR |= 0x40; 
 }
 
 void ADC_init(unsigned char tongdao)
 {
 tongdao&=0X0F;
 if(tongdao<8)
 {
  (P1M0 |= 1 << ((tongdao&0x07))) ;
  (P1M1 &= ~(1 << ((tongdao&0x07)))) ;
 }
 else
 {
  (P0M0 |= 1 << ((tongdao-8))) ;
  (P0M1 &= ~(1 << ((tongdao-8)))) ;
 }
 
 ADCCFG = 0x2f;                               
 ADC_CONTR = 0x80+tongdao;         
 EADC = 1;                                    
 EA = 1;
 ADC_CONTR |= 0x40;                           
 }
 
 
 char MEMORY_BUF[512];
 
 
 
 long counter0;                         
 void mainTask(void) _task_ 0  
 {  
 BGV_DAT=* BGV;       
 McuInit();
 memset(MEMORY_BUF,0,512);      
 init_mempool(MEMORY_BUF,512);   
 
 os_create_task (1);    
 os_create_task (2);    
 
 
 os_create_task (5);  
 
 
 os_delete_task (0); 
 ADC_init(0x00);
 while(1)
 { 	static int AD_Res;
 counter0++; 	
 os_wait(0x01, 0, 0);
 res=2495L-((res*2495L)>>12);
 AD_Res=(abs(AD_Res-res)<10)?(AD_Res+res)/2:res;
 res=0;
 msg_queue_in(0x09,AD_Res);
 ADC_init(0x00);
 ADC_CONTR |= 0x40;                           
 os_wait(0x02, 0.5*200, 0);
 }
 }
